package algorithm.algorithm;

/**
 * @Description : 测试递归算法
 * Created by cyd on 2021-02-06 21:49:00
 */
public class RecursionTest {
    public static void main(String[] args) {
        // RecursionTest.test(4);
        System.out.println(RecursionTest.factorial(4));
    }

    public static void test(int n) {
        if (n > 2) {
            test(n - 1);
        }
        System.out.println("n:" + n);
    }

    // 递归
    public static int factorial(int n) {
        if (n == 1) {
            return 1;
        } else {
            return (factorial(n - 1)) * n;
        }
    }
}
